<template>
  <div class="tab-control">
    <div v-for="(item, index) in title" :key="index" 
    class="tab-control-item" 
    :class="{active:(index === activeindex)}"
    @click="itemonclick(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
  export default {
    name: "TabControl",
    props: {
      title:{
        type: Array,
        default(){
          return []
        }
      }
    },
    data () {
      return {
        activeindex:0
      }
    },
    methods: {
      itemonclick(index){
        this.activeindex = index;
        this.$emit('tabclick', index)
      }
    }
  }
</script>
<style scoped>
.tab-control{
  display: flex;
  text-align: center;
  font-size: 0.9375rem;
  height: 2.5rem;
  line-height: 2.5rem;
  background: #fff;
}
.tab-control-item{
  flex: 1;
}
.tab-control-item span{
  padding: 0.3125rem;
}
.active{
  color: var(--color-tint);
}
.active span{
  border-bottom: 0.1875rem solid var(--color-tint);
}
 
</style>